<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$pagetitle}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
  <link rel="stylesheet" href="/static/admin/style/global.css" media="all">
</head>
<body>

	<div class="layui-fluid">
	<div class="layui-card">

	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
	<div class="layui-form-item">


	  <div class="layui-inline">
		  <a class="layui-btn layuiadmin-btn-list iframe" href="{:url('add')}" data-width="100%" data-height="100%">增加栏目</a>
	  </div>          
	</div>
	</div>

	<div class="layui-card-body">
	<form class="layui-form" action="{:url('updateSort')}" onsubmit="return save_form(this,success_fun)" lay-filter="component-form-element">
	<table class="layui-table">
	  <colgroup>
		<col width="150">
		<col width="150">
		<col width="200">
		<col>
	  </colgroup>
	  <thead>
		<tr>
			<th width="3%">排序</th>
			<th style="width:8%">catid</th>
			<th style="width:20%">栏目名称 (点击选中)</th>
			<th style="text-align: left;width:27%">栏目关系</th>
			<th style="width:10%">系统模型</th>
			<th style="width:6%">状态</th>                    
			<th style="width:17%">操作</th>
		</tr> 
	  </thead>
	  <tbody>
	  {foreach $data as $key=>$v}
		<tr>
			<td style="text-align: center;"><input type='text' value="{$v.sort}" name="sort[]" autocomplete="off" style="width:50px;text-align: center;"><input type='hidden' value="{$v.catid}" name="catids[]"></td>
			<td style="text-align: center;"><input type="text" value="{$v.catid}" onclick="this.select()" style="width:50px; margin: 0px; padding: 2px ; text-align: center; font-weight: 600"></td>
			<td style="text-align: center;"><input type="text" value="{$v.name}" onclick="this.select()" style="width:100px;margin: 0px;padding:2px; font-weight: 600"></td>
			<td class="tab-title"><a href="{:caturl($v['catid'])}" target="_blank">{$v.str|raw}{$v.name}</a></td>       
			<td class="center">{$GLOBALS['model'][$v['modelid']]['name']}</td>                                          
			<td class="center">
                            <input type="checkbox" name="status" lay-filter="status" value="{$v.catid}" class="status" title="启用" {if $v.status}checked{/if}>
			</td>
			<td class="center">
			  
            <ul class="layui-nav nav-button" lay-filter="component-nav">
              <li class="layui-nav-item layui-this">
                <a href="javascript:;">添加</a>
                <dl class="layui-nav-child">
                  <dd><a href="{:url('add',array('pid'=>$v['pid'],'catid'=>$v['catid'],'modelid'=>$v['modelid']))}" class="iframe" data-width="100%" data-height="100%">同级栏目</a></dd>
                  <dd><a href="{:url('add',array('pid'=>$v['catid'],'catid'=>$v['catid'],'modelid'=>$v['modelid']))}" class="iframe" data-width="100%" data-height="100%">子级栏目</a></dd>
                </dl>
              </li>
            </ul>			  
			  
			<a href="{:url('update',array('catid'=>$v['catid']))}" class="layui-btn layui-btn-sm iframe" title="修改页面"  data-width="100%" data-height="100%"><i class="layui-icon">&#xe642;</i></a>
			<a href="{:url('delete',array('catid'=>$v['catid']))}" class="layui-btn layui-btn-sm ajax_del"><i class="layui-icon">&#xe640;</i></a>
		  </td>
		</tr>
	   {/foreach}
	  </tbody>
	</table>
	  <div class="layui-inline">
		  <button class="layui-btn layuiadmin-btn-list" data-type="add">排序</button>
	  </div>    
	</form>				  
	</div>
      
	</div>
</div>

  <script src="/static/admin/layui/layui.js"></script>
  <script src="/static/js/jquery.min.js"></script>    
  <script src="/static/js/globals.js"></script>  
  <script>
  layui.config({
    base: '/static/admin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,admin = layui.admin
    ,element = layui.element
    ,form = layui.form;
    element.render('nav', 'component-nav');
    form.render(null, 'component-form-element');
    element.render('breadcrumb', 'breadcrumb');
    form.on('checkbox(status)', function(data){
      var checked=data.elem.checked;
	  var status=checked?1:0;
      var id=data.value;
      ajax_del("{:url('setStatus')}?catid="+id+"&status="+status,function(msg,data){
		  layer.msg("设置成功");
	  });
    });
	  form.on('checkbox(display)', function(data){
		  var checked=data.elem.checked;
		  var status=checked?1:0;
		  var id=data.value;
		  ajax_del("{:url('setDisplay')}?catid="+id+"&status="+status,function(msg,data){
			  layer.msg("设置成功");
		  });
	  });
	

  });
  function success_fun(msg,data){
	layer.msg("设置成功");
	window.location.reload();
  }
  </script>

</body>
</html>
